package com.myjar.excel.serializer;

import org.apache.poi.ss.usermodel.Cell;

public class CharacterCodec implements ObjectSerializer<Character> {

    final static CharacterCodec instance = new CharacterCodec();

    private CharacterCodec() {
    }

    @Override
    public void write(Cell cell, Character character) {
        cell.setCellValue(character + "");
    }

    @Override
    public Character read(Cell cell) {
        String ret = cell.getStringCellValue();
        return (ret == null || ret.length() == 0)
                ? '\0'
                : ret.charAt(0);
    }
}
